
jws.GlobisPlugin = {
	// if namespace is changed update server plug-in accordingly!
	NS: "org.jwebsocket.plugins.GlobisPlugin",
	//Method is called when a token has to be progressed
	processToken: function(paToken) {
		// check if namespace matches

		aToken = paToken;

		if (aToken.ns === jws.GlobisPlugin.NS) {

			if (aToken.reqType === "coordSend") {

				getElementList(aToken, listElement, prevElement);
			}
			else if (aToken.reqType === "sendId") {

				elementId = aToken.elementId;

			}
			else if (aToken.reqType === "dragStart") {

				hasClass();

			}
			else if (aToken.reqType === "dragStop") {

				var elemenToInsert = parent.document.getElementById(aToken.idClass);

//				$jquery(elemenToInsert).css('top', $jquery('.' + elementAux.class).position().top);
//
//				$jquery(elemenToInsert).css('left', $jquery('.' + elementAux.class).position().left);
//
//				$jquery(elemenToInsert).css('position', $jquery('.' + elementAux.class).css('position'));
//
//				$jquery(elemenToInsert).width($jquery('.' + elementAux.class).width());
//
//				$jquery(elemenToInsert).height($jquery('.' + elementAux.class).height());
//
//				$jquery("." + elementAux.class).replaceWith(elemenToInsert);
				
				insertElement(elemenToInsert, $jquery("." + elementAux.class));

			}

		}
	},
	dragStart: function() {
		if (this.isConnected()) {
			//create the request token
			var lToken = {
				ns: jws.GlobisPlugin.NS,
				type: "dragStart",
			};

			this.sendToken(lToken);//send it
		}
	},
	penduloTrue: function(aOptions) {
		if (this.isConnected()) {
			//create the request token
			var lToken = {
				ns: jws.GlobisPlugin.NS,
				type: "penduloTrue",
			};

			this.sendToken(lToken, aOptions);//send it
		}
	},
			coordSend: function(coord, aOptions) {
		if (this.isConnected()) {
			//create the request token
			var lToken = {
				ns: jws.GlobisPlugin.NS,
				type: "coordSend",
				x: coord.x,
				y: coord.y
			};

			this.sendToken(lToken, aOptions);//send it
		}
	},
	sendId: function(id, aOptions) {
		if (this.isConnected()) {
			//create the request token
			var lToken = {
				ns: jws.GlobisPlugin.NS,
				type: "sendId",
				elementId: id
			};

			this.sendToken(lToken, aOptions);//send it
		}
	},
	dragStop: function(id, aOptions) {
		if (this.isConnected()) {
			//create the request token
			var lToken = {
				ns: jws.GlobisPlugin.NS,
				type: "dragStop",
				idClass: id

			};

			this.sendToken(lToken, aOptions);//send it
		}
	},
	register: function(type, aOptions) {
		if (this.isConnected()) {
			//create the request token
			var lToken = {
				ns: jws.GlobisPlugin.NS,
				type: 'register',
				registerType: type
			};
			this.sendToken(lToken, lToken);//send it
		}
	}
};
